@echo off
call :main

::----------------------------------------------------
setlocal enabledelayedexpansion
rem 定义函数：获取字符串长度
:getStringLength
set "str=%~1"
set "len=0"
:loop
if defined str (
    set "str=!str:~1!"
    set /a "len+=1"
    goto loop
)
exit /b  rem 返回调用点
endlocal

::----------------------------------------------------
:main
call :getStringLength "Hello, World!"
echo Length of string is: %len%
call :getStringLength "Hello"
echo Length of string is: %len%

pause
